//Sat Jul 17 20:35:41 CDT 2010
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class SubAnagrams
{
private:
	int v[550][550];
public:
	int maximumParts(vector<string> suppliedWord)
	{
		memset(v, 0, sizeof(v));
		string str = "";
		for (int i = 0; i < suppliedWord.size(); i++)
			str += suppliedWord[i];
		int N = str.size();
		int ret = 0;
		for (int i = 0; i < N; i++)
			v[0][i] = 1;
		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j <= i; j++)
			{
				vector<int> count(26, 0);
				for (int k = j; k <= i; k++)
				{
					count[str[k] - 'A']++;
				}
				for (int k = j - 1; k >= 0; k--)
				{
					count[str[k] - 'A']--;
					if (count[str[k] - 'A'] < 0)
						break;
					if (v[k][j - 1] > 0)
						v[j][i] = max(v[j][i], v[k][j - 1] + 1);
				}
				ret = max(ret, v[j][i]);
			}
		}
		return ret;
	}
};

//v[i][j] record the max number of the divideable string index from i to j;
//1st, count the characters from i to j;
//2nd, find the maximum from the previous string to find out:
//	sub-1st, string i to j can cover the previous string, if not, break;
//  sub-2nd, string i to j will take the greatest number of which string can satisfy the sub-1st condition;
//return the ret;
